using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;

namespace M0
{
    public class Resource加载 : BaseSingle<Resource加载>,ISingle
    {
        private Dictionary<string, Object> 加载缓存 = new Dictionary<string, Object>();

        public T Load<T>(string str) where T: Object
        {
            Object 缓存值 = null;
            if (加载缓存.ContainsKey(str))
            {
                缓存值 = 加载缓存[str];
            }
            else
            {
                缓存值 = Resources.Load<T>(str);
                加载缓存.Add(str,缓存值);
            }

            if (typeof(T).IsSubclassOf(typeof(Component))
            || typeof(T) == typeof(GameObject))
            {
                var copy = M.缓存.F创建($"Resource加载{str}", 缓存值,null);
                return copy as T;
            }
            else
            {
                return 缓存值 as T;
            }
        }
    
        public void Init()
        {
        
        }
    }
}
